<?php include('./public/header.php') ?>
<link href="../css/school-list.css" rel="stylesheet">

<body>
<div class="my-container">
    <div class="content">
        <div id="swiper" class="swiper-container">
            <div class="swiper-wrapper">
                <!-- <div class="swiper-slide">
                    <div class="slide-item">
                        <div class="wrap">
                            <img src="../img/1.png" alt="" /><p>伟童幼儿园</p>
                        </div>
                    </div>
                </div> -->
            </div>
            <div class="swiper-button-next"></div>
            <div class="swiper-button-prev"></div>
            <div class="swiper-scrollbar"></div>
        </div>
    </div>
</div>

</body>
<?php include('./public/footer.php') ?>
<script>
var datas = {
    urlGetList: parameters.urlSchoolList,
    swiper: new Swiper('#swiper', {
            spaceBetween: 20,
            // slidesPerView: 4,
            scrollbar: {
                el: '.swiper-scrollbar',
            },
            // centeredSlides: true,
            navigation: {
                nextEl: '.swiper-button-next',
                prevEl: '.swiper-button-prev',
              },
            noSwipingClass: 'no-swiping',
            // freeMode: true,
            slidesPerView: 'auto',
        })
};
var methods = {
    getList: function() {
        $.ajax({
            url: datas.urlGetList,
            type: 'POST',
            data: {
                user_id: getCookie('id'),
                user_name: getCookie('name'),
                role: getCookie('role'),
            },
        })
        .done(function(data) {
            var data = JSON.parse(data);
            setTimeout(function() {
                for (var i in data) {
                    datas.swiper.appendSlide('\
                        <div class="swiper-slide">\
                            <div class="slide-item ' + (data[i].priority == 1 ? 'active' : 'not') + '">\
                                <div class="wrap">\
                                    <img src="' + parameters.srcImg + data[i].thumb + '" alt="" /><p>' + data[i].school_name + '</p>\
                                </div>\
                            </div>\
                        </div>\
                    ');
                }
            }, 300);

            console.log("success");
        })
        .fail(function() {
            console.log("error");
        })
        .always(function() {
            console.log("complete");
        });

    }
};
var mounted = function() {
    methods.getList();
    $('#swiper').on('click', '.slide-item', function() {
        if ($(this).is('.active')) {
            window.location.href = '../output/index.html';
        } else {
            alert('没有该权限');
        }
    });
};

mounted();
</script>
